home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / program / pcl4p51.zip / TVTERM.PAS < prev    next >
Pascal/Delphi Source File  |  1996-06-04  |  2KB  |  77 lines

  1. program TVterm;
  2.  
  3. (*********************************************)
  4. (*                                           *)
  5. (*          TVTERM.PAS      July 1993        *)
  6. (*                                           *)
  7. (*  TVTERM is provided as a simple terminal  *)
  8. (*  program which is provided as an example  *)
  9. (*  of how to use PCL4P with Turbo Vision.   *)
  10. (*                                           *)
  11. (*  This program is donated to the Public    *)
  12. (*  Domain by MarshallSoft Computing, Inc.   *)
  13. (*                                           *)
  14. (*********************************************)
  15.  
  16. uses Objects, Drivers, App, PCL4P;
  17.  
  18. type
  19.   PTVtermApp = ^TTVtermApp;
  20.   TTVtermApp = object(TApplication)
  21.     procedure HandleEvent(var Event: TEvent); virtual;
  22.     procedure Idle; virtual;
  23.   end;
  24.  
  25. (* global comm variables *)
  26.  
  27. var
  28.    RetCode : Integer;
  29.    BufPtr  : Pointer;
  30.    BufSeg  : Integer;
  31.  
  32. procedure TTVtermApp.Idle;
  33. begin
  34.   (* copy any received serial input to the screen *)
  35.   RetCode := SioGetc(COM1,0);
  36.   if RetCode>-1 then write( char(RetCode) )
  37. end;
  38.  
  39. { TTVtermApp }
  40.  
  41. procedure TTVtermApp.HandleEvent(var Event: TEvent);
  42. begin
  43.   TApplication.HandleEvent(Event);
  44.   (* process the event *)
  45.   case Event.What of
  46.       evKeyDown:
  47.         begin
  48.           (* transmit any keyboard input *)
  49.           RetCode := SioPutc(COM1,Event.CharCode);
  50.         end;
  51.   else ClearEvent(Event);
  52.   end
  53. end;
  54.  
  55. var
  56.   TVtermWorld: TTVtermApp;
  57.  
  58. begin
  59.   (* initialize the comm *)
  60.   GetMem(BufPtr,1024+16);
  61.   BufSeg := Seg(BufPtr^) + ((Ofs(BufPtr^)+15) SHR 4);
  62.   RetCode := SioRxBuf(COM1, BufSeg, Size1024);
  63.   if SioInfo('I') > 0 then
  64.     begin
  65.       GetMem(BufPtr,128+16);
  66.       BufSeg := Seg(BufPtr^) + ((Ofs(BufPtr^)+15) SHR 4);
  67.       RetCode := SioTxBuf(COM1, BufSeg, Size128);
  68.     end;
  69.   RetCode := SioReset(COM1,Baud2400);
  70.   (* run Turbo Vision *)
  71.   TVtermWorld.Init;
  72.   TVtermWorld.Run;
  73.   TVtermWorld.Done;
  74.   (* shut down the comm *)
  75.   RetCode := SioDone(COM1);
  76. end.
  77.